﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using MichaelKappel.Net.CSharp;
using System.IO;

namespace phudieuhungthinh
{
    public partial class _Default : System.Web.UI.Page
    {
        const string HomeFolder = "HomeFolder";
        static object obj = new object();

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        [WebMethod]
        public static IList<string> GetHomeImages()
        {
            var images = HelperCache.Get<IList<string>>(HomeFolder);
            if (images == null)
                lock (obj)
                {
                    var folder = HttpContext.Current.Server.MapPath("~" + Define.HighlightsFolder);
                    images = (from x in new DirectoryInfo(folder).GetFiles("*.jpg")
                              select "/hinh-anh-noi-bat/dieu-khac/" + x.Name).ToList();
                    HelperCache.Add(HomeFolder, images, HelperCache.CachingTime.ShortTermSliding);
                }

            return images;
        }
    }
}
